﻿using B.S.Material.Domain;
using B.S.Material.Domain.BOM;
using B.S.Material.Domain.Production_rejection;
using B.S.Material.Domain.Scraps;
using SqlSugar;

namespace B.S.Material.Infrastructrue
{
    public class SDbContext
    {
        public SqlSugarClient db { get; set; }
        public SDbContext()
        {
            db = new SqlSugarClient(new ConnectionConfig()
            {
                DbType = DbType.SqlServer,//使用Mysql数据库
                ConnectionString = "Server=10.223.8.81;DataBase=wanghaoran1;Uid=sa;Pwd=123456;Encrypt=True;TrustServerCertificate=True;",
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute,

            });
            db.DbMaintenance.CreateDatabase();
            //物料管理主表
            db.CodeFirst.InitTables(typeof(Materials));
            //物料管理子表
            db.CodeFirst.InitTables(typeof(MaterialsChild));
            //上传文件图片
            db.CodeFirst.InitTables(typeof(upload));
            //生产领料主
            db.CodeFirst.InitTables(typeof(MaterialsPicking));
            //生产领料明细表
            db.CodeFirst.InitTables(typeof(MaterialsPickingDetail));

            //生产补料主
            db.CodeFirst.InitTables(typeof(Feedings));
            //生产补料明细表
            db.CodeFirst.InitTables(typeof(FeedDetailss));

            //生产退料主
            db.CodeFirst.InitTables(typeof(Stripping));
            //生产退料明细表
            db.CodeFirst.InitTables(typeof(StrippingDetails));


            //生产废料主
            db.CodeFirst.InitTables(typeof(ProductionWasteZ));
            //生产废料明细表
            db.CodeFirst.InitTables(typeof(ScrapBreakdown));

        }
    }
}
